package reflect;

import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.Scanner;

public class Test2 {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个类:");
        String className = sc.nextLine();
        Class<?> cls = Class.forName(className);
        Object obj = cls.newInstance();
        Method[] methods = cls.getMethods();
        for (Method method : methods) {
            if (method.getName().contains("s") &&
                    method.getParameterCount() == 0 &&
                    method.getModifiers() == Modifier.PUBLIC) {
                System.out.print(method.getName()+"()");
                method.invoke(obj);
                System.out.println();
            }
        }
    }
}
